function cntForm_startup()
{
    if( $('form#cntForm').length > 0 )
    {
        $('form#cntForm').ajaxForm( {
            beforeSubmit: null,
            success:      cntForm_validate_response,
            dataType:     'json'
        } );
    }

    return true;
}

function cntForm_submit()
{
    if( $('form#cntForm').length == 0 )
    {
        return false;
    }

    buggy_clean();

    $('.handler__cntForm__before_submit_function').each(
    function()
    {
        eval( $(this).attr('function') );
        return true;
    } );

    $('form#cntForm').submit();

    return true;
}
    
function cntForm_validate_response( responseBody, responseStatus )
{
    if( responseStatus == 'success' && responseBody )
    {
        switch( responseBody.status )
        {
            case 'error':
            {
                buggy_markup( responseBody.error_messages );
                return true;
            }

            case 'error_alert':
            {
                alert( responseBody.error_message );
                return true;
            }

            case 'complite':
            {
                if( responseBody.link_redirect )
                {
                    location.href = responseBody.link_redirect;
                }
                else
                {
                    alert('Done!');
                }
                return true;
            }

            default:
            {
                alert('Undefined response status');
                return false;
            }
        }
    }

    return true;
}

function cntForm_Content_ChangeSourceGroup( new_group_id )
{
    $('.source_selector').hide();
    $('.source_selector_'+new_group_id).show();
    return true;
}

function cntForm_Content_IngredientsShowBox()
{
    $('.IngredientsShowerBox').hide();
    $('.IngredientsBox').show();
    return true;
}

function cntForm_Content_RefsShowBox()
{
    $('.RefsShowerBox').hide();
    $('.RefsBox').show();
    return true;
}
